package com.futureweaver.service.impl;

import com.futureweaver.domain.Employee;
import com.futureweaver.mapper.EmployeeMapper;
import com.futureweaver.service.EmployeeService;
import com.futureweaver.request.vo.LoginVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper mapper;

    @Override
    public boolean login(LoginVO vo) {
        Employee result = mapper.queryByUsernameAndPassword(vo);
        return result != null;
    }

    @Override
    public List<Employee> queryByDepartment(String departmentId, String departmentNo) {
        return mapper.queryByDepartment(departmentId, departmentNo);
    }

    @Override
    public List<Employee> queryByDeptIdAndLevelId(String deptId, String levelId) {
        return mapper.queryByDeptIdAndLevelId(deptId, levelId);
    }

    @Override
    public Employee loadUserByUsername(String username) throws UsernameNotFoundException {
        Employee result = mapper.queryByUsername(username);
        return result;
    }
}
